package com.xt.purchasingsystem.controller.productDesign.proFileManagement.productFileRegistrtion;

import com.xt.purchasingsystem.dto.DFileDto;
import com.xt.purchasingsystem.model.DFile;
import com.xt.purchasingsystem.service.productDesignService.proFileManageService.proFileRegistrtionService.ProductFileRegistrtionService;
import com.xt.purchasingsystem.utils.Result;
import com.xt.purchasingsystem.utils.SerialNumberUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;


/**
 * @author dm
 * @date 2020/3/9 10:57
 */
@RestController

@RequestMapping(value = "/productFileRegistrtion")
public class productFileRegistrtionController {
    @Autowired
    private ProductFileRegistrtionService productFileRegistrtionService;


    @PostMapping("/insertAllProductFile")
    public Result productFileRegistrtion(@RequestBody DFile form) {
        form.setProductId(SerialNumberUtil.productSerNumber());
        return productFileRegistrtionService.insert(form);
    }

    @GetMapping("/checkProductName/{productName}")
    public Result checkProductName(@PathVariable("productName") String productName) throws Exception {
        String name = new String(productName.getBytes(), "utf-8");
        System.out.println(name);
        return productFileRegistrtionService.checkProductName(name);
    }

    //     *  多条件分页查询所有未删除已审核是物料的产品档案的接口
    @PostMapping("/getAllDFileIsMaterial")
    public Result getAllDFileIsMaterial(@RequestBody DFileDto dFileDto) {
        return productFileRegistrtionService.getAllDFileIsMaterial(dFileDto);
    }

    @PostMapping("/getAllNoQuotationBySupplierId")
    public Result getAllNoQuotationBySupplierId(@RequestBody DFileDto dFileDto) {
        return productFileRegistrtionService.getAllNoQuotationBySupplierId(dFileDto);
    }

}
